<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cmcc.operator.*" %>
<%@include file="../checkLoginSession.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% 
	Operator operator = (Operator)session.getAttribute("operator");
	System.out.println("addOperator.jsp----------------");
	operator.print();
	if(!operator.getIs_admin().equals("Y")){
		response.sendRedirect("../frameSet/blank.jsp?noright=nonewopratorright");
		return;
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'addOperator.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<LINK href="style/style.css" type=text/css rel=stylesheet>


  </head>
<script type= "text/javascript">
       var xmlHttp;
       var flagid=false;
       var flagname = false;
       var falgpwd = false;
       
        function createXMLHttpRequest() {
               if (window.ActiveXObject) {
                     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP" );
              }
               else if (window.XMLHttpRequest) {
                     xmlHttp = new XMLHttpRequest();
              }
       }

        function createQueryString() {
               var userid = document.getElementByIdx_x("userid").value;
               var queryString = "userid=" + userid;
               return queryString ;
       }
       
        function checkIdRecept() {
              var operator_id = document.getElementById("operator_id").value;
              //alert(operator_id);
              if(operator_id.length<4){
              		var id = document.getElementById("id"); 
                    id.innerHTML = "<font color=red>X</font>至少四位数字"; 
                    flagid= false;
                    return;   
              }
              createXMLHttpRequest();
              xmlHttp.onreadystatechange = handleStateChange;
              var url="operate/checkIdRepect.jsp?" ;
              xmlHttp.open( "GET", url+"operator_id=" +operator_id, true );
              xmlHttp.send( null);
                     
       }
        function handleStateChange() {
               if (xmlHttp.readyState == 4) {
                      if (xmlHttp.status == 200) {
                           
                           var Data = xmlHttp.responseText;
                           var str= Data.substring(0, 2);
                           //alert(Date);
                           if(str==="RE"){
                           		//alert("id is exit!");
                           		var id = document.getElementById("id"); 
                        		id.innerHTML = "<font color=red>X</font>该id已存在" ; 
                        		flagid= false;                         		
                           }else if(str==="NO"){
                           		var id = document.getElementById("id"); 
                        		id.innerHTML = "<font color=green>√</font>" ;   
                        		flagid = true;        
                           }                                          
                     }
              }
       }

</script>
  
  	<body >
		<script type="text/javascript">
 			function checkname(obj){
 				var name = obj.value;
 				var namediv = document.getElementById("name"); 
 				if(name.length<4){					
                    namediv.innerHTML = "<font color=red>X</font>该name不可使用" ;
                    flagname = false;
 				}else{
 					namediv.innerHTML = "<font color=green>√</font>" ;
 					flagname=true;
 				}
 			}
 			
 			function checkpwd(){
 				var pwd1 = document.getElementById("operator_pwd1").value;
 				var pwd2 = document.getElementById("operator_pwd2").value;
 				var divpwd2 = document.getElementById("divpwd2");
 				var divpwd1 = document.getElementById("divpwd1");
 				//alert(pwd1+"-------"+pwd2);
 				if(pwd1==pwd2 && pwd1.length>=6){
 					//alert("yiyang");
 					divpwd1.innerHTML = "<font color=green>√</font>";
 					divpwd2.innerHTML = "<font color=green>√</font>";
 					flagpwd = true;
 				}else if(pwd1.length<6){
 					divpwd1.innerHTML = "<font color=red>X</font>至少六位数字";
 					divpwd2.innerHTML = "<font color=red>X</font>";
 					flagpwd = false;
 				}else {
 					divpwd1.innerHTML = "<font color=red>X</font>";
 					divpwd2.innerHTML = "<font color=red>X</font>两次密码不一致";
 					flagpwd = false;
 				}
 			}
 			
 			function check(){
 				if(flagid&&flagpwd&&flagname){
 					return true;
 				}
 				return false;
 			}
	    </script>
		
		<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
			<TBODY>
				<TR>
					<TD height=25>
						<font size="2">您现在的位置：>>新增操作员</font>
						<hr>
					</TD>
				</TR>
				<TR>
					<TD>
						<IMG height=2 src="images\blank(1).gif" width=574>
					</TD>
				</TR>
			</TBODY>
		</TABLE>
		<br><br><br>
		<TR align="top">
			<TD height="600" bgColor=#f1f3f9>
				<form method="POST" action="operate/checkAdd.jsp"
					onsubmit="return check()">
					<input type="hidden" name="flag" value="submitnewoperator">
					<table  cellspacing="1" class="form_table1" align="center">
						<tr>
							<td width="20%">
								&nbsp;&nbsp;&nbsp;登录ID：
							</td>
							<td class="formtb_right">
								<input type="text" name="operator_id" id="operator_id" onblur="checkIdRecept()">								
							</td>
							<td  width="20%"><div id="id">*至少四位数字</div></td>
						</tr>
						<tr>
							<td width="20%">
								&nbsp;&nbsp;&nbsp;姓&nbsp; 名：
							</td>
							<td class="formtb_right">
								<input type="text" name="operator_name" onblur="checkname(this)">
								
							</td>
							<td  width="20%"><div id="name">*不超过20位</div></td>
						</tr>
						<tr>
							<td width="20%">
								&nbsp;&nbsp;&nbsp;密&nbsp; 码：
							</td>
							<td class="formtb_right">
								<input type="password" name="operator_pwd1" id="operator_pwd1" onblur="checkpwd()">
								
							</td>
							<td  width="20%"><div id="divpwd1">*至少六位数字</div></td>
						</tr>
						<tr>
							<td width="20%">
								&nbsp;&nbsp;&nbsp;密码确认：
							</td>
							<td class="formtb_right">
								<input type="password" name="operator_pwd2" id="operator_pwd2" onblur="checkpwd()">
								 
							</td>
							<td  width="20%"><div id="divpwd2">*至少六位数字</div></td>
						</tr>
						

						<tr>
							<td width="20%">
								&nbsp;&nbsp;&nbsp;是否管理员：
							</td>
							<td class="formtb_right">
								<input type="radio" value="Y" name="is_admin">
								是 &nbsp;
								<input type="radio" value="N" name="is_admin" checked="checked">
								否
							</td>
							<td  width="20%"></td>
						</tr>
					</table>
					<br>
					<br>
					<p align="center">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="submit" value="提交">
						&nbsp;&nbsp;&nbsp;
						<input type="reset" value="全部重写">
					</p>
				</form>
			</TD>
		</TR>
		<font color="red">
		  </font>
	</body>

</html>
